/*
 * TestDriver.cpp
 *
 *  Created on: Mar 1, 2011
 *      Author: Craig Wilson
 */
#include"../utils/src/CommandRunner.cpp"
#include"../utils/src/FileInputStream.cpp"
#include"../utils/src/FileSystem.cpp"
#include"../utils/src/HTMLToken.cpp"
#include"../utils/src/HTMLTokenizer.cpp"
#include"../utils/src/HTTPInputStream.cpp"
#include"../utils/src/StringUtil.cpp"
#include"../utils/src/URLInputStream.cpp"



#include <iostream>
#include <stdlib.h>
#include "ExternValues.h"
#include "DataStructureTests.cpp"
#include "URLTests.cpp"
#include "PageTests.cpp"
#include "OccurrenceTests.cpp"
#include "UtilTests.cpp"

	using namespace std;

	int code;


void DataStructs(){
	cout << "\t\tTesting BSTs(with strings)...";
	if((code=BSTTests())==0)
		cout << "\t  PASSED" << endl;
	else
		cout << "\tFAILED (return code: " << code <<")" << endl;

	cout << "\t\tTesting LinkLists(with strings)...";
	if((code=LLTests())==0)
		cout << "PASSED" << endl;
	else
		cout << "FAILED (return code: " << code <<")" << endl;
}

void URLs(){
	cout << "\t\tTesting URLs...";
	if ((code=URLTests())==0)
		cout << "\t\tPASSED" << endl;
	else
		cout << "\t\tFAILED (return code: " << code <<")" << endl;

	cout << "\t\tTesting URLValidator...";
	if ((code=URLValidatorTests())==0)
		cout << "\tPASSED" << endl;
	else
		cout << "\tFAILED (return code: " << code <<")" << endl;

	cout << "\t\tTesting URLHistory...";
		if ((code=URLHistoryTests())==0)
			cout << "\tPASSED" << endl;
		else
			cout << "\tFAILED (return code: " << code <<")" << endl;

	cout << "\t\tTesting URLQueue...";
	if ((code=URLQueueTests())==0)
		cout << "\tPASSED" << endl;
	else
		cout << "\tFAILED (return code: " << code <<")" << endl;

}

void Pages(){
	cout << "\t\tTesting Page...";
	if ((code=PageTests())==0)
		cout << "\t\tPASSED" << endl;
	else
		cout << "\t\tFAILED (return code: " << code <<")" << endl;

	cout << "\t\tTesting PageHistory...";
	if ((code=PageHistoryTests())==0)
			cout << "\tPASSED" << endl;
		else
			cout << "\tFAILED (return code: " << code <<")" << endl;
}

void Occurrences(){
	cout << "\t\tTesting Occurrence...";
	if ((code=OccurrenceTests())==0)
		cout << "\tPASSED" << endl;
	else
		cout << "\tFAILED (return code: " << code <<")" << endl;

	cout << "\t\tTesting OccurrenceSet...";
	if ((code=OccurrenceSetTests())==0)
		cout << "PASSED" << endl;
	else
		cout << "FAILED (return code: " << code <<")" << endl;

	cout << "\t\tTesting KeyWordIndex...";
	if ((code=KeyWordIndexTests())==0)
		cout << "\tPASSED" << endl;
	else
		cout << "\tFAILED (return code: " << code <<")" << endl;
}

void Utils(){
	cout << "\t\tTesting StopWordList...";
	if ((code=StopWordListTests())==0)
		cout << "\tPASSED" << endl;
	else
		cout << "\tFAILED (return code: " << code <<")" << endl;
	cout << "\t\tTesting URLDownloader...";
	if ((code=URLDownloaderTests())==0)
		cout << "PASSED" << endl;
	else
		cout << "FAILED (return code: " << code <<")" << endl;

	cout << "\t\tTesting HTMLParser...";
	if ((code=HTMLParserTests())==0)
		cout << "\tPASSED" << endl;
	else
		cout << "\tFAILED (return code: " << code <<")" << endl;

	cout << "\t\tTesting XMLGenerator...";
	if ((code=XMLGeneratorTests())==0)
		cout << "\tPASSED" << endl;
	else
		cout << "\tFAILED (return code: " << code <<")" << endl;
}


int main(){
	try{

		cout << "\n\tData Structures Classes:" << endl;
		DataStructs();

		cout << "\n\tURL Classes:" << endl;
		URLs();

		cout << "\n\tPage,Occurrence, and KeyWordIndex Classes:" << endl;
		Pages();
		Occurrences();

//		cout << "\n\tUtility Classes:" << endl;
//		Utils();
	}
	catch(...){
		cout << "Something broke" << endl;
	}

}
